import React from 'react'
import './index.scss'
import {Layout, Menu} from 'antd';
import {IsLogin} from "../LoginState";
import {useLocation} from "react-router-dom/cjs/react-router-dom";
import {useHistory} from "react-router-dom";
import FRAS from '../../assets/images/FRAS.png'

const {Header} = Layout;

function MyHeader() {
  // const [loginState, setLoginState] = useState(false)
  const location = useLocation()
  const history = useHistory()
  const forewordFirstPage = () => {
    if (sessionStorage.getItem('my_token')){
      history.push('/main')
    }
    else{
      history.push('/')
    }
  }
  return (
    <Header className="header">

      <div className="header-box">
        <img src={FRAS} alt="fras" className="logo"/>
        <Menu theme="light" mode="horizontal" selectable={false}>
          <Menu.Item key={'首页'} onClick={forewordFirstPage}>首页</Menu.Item>
          <Menu.Item key={'功能'}>功能</Menu.Item>
          <Menu.Item key={'帮助'}>帮助</Menu.Item>
          <Menu.Item key={'反馈'}>反馈</Menu.Item>
        </Menu>
        {
          location.pathname === '/' ? <></> :
            <div className="header-right">
              {window.sessionStorage.getItem('my_token') ? <IsLogin msgHandleClick={()=>{}} src={''}/> : <></>}
            </div>
        }
      </div>

    </Header>
  )
}

export default MyHeader